package com.raibaz.atm;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.raibaz.atm.businesslogic.AtmFetcher;
import com.raibaz.atm.businesslogic.Instruction;

public class Atm extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        

        LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        
        AtmLocationListener listener = new AtmLocationListener(this);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener);
        
        
        Button btn = (Button)findViewById(R.id.ButtonGo);                               
        btn.setOnClickListener(new OnClickListener() {			
			
			public void onClick(View v) {
				EditText etFrom = (EditText)findViewById(R.id.From);
		        EditText etTo = (EditText)findViewById(R.id.To);
		        final String from = etFrom.getText().toString();
		        final String to = etTo.getText().toString();
				ArrayList<Instruction> instructions = AtmFetcher.fetchPath(from, to);
				for(Instruction i : instructions) {
					System.out.println(i);
				}
				
			}
		});
        
        
//        ArrayList<Instruction> instructions = AtmFetcher.fetchPath("piazzale loreto", "cosimo del fante");
//        for(Instruction i : instructions) {
//        	System.out.println(i);
//        }
        
    }
}